package com.ojoin.trade.supplyloan_core.web.domain;

import java.io.Serializable;
import java.util.Date;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ojoin.trade.common.utils.Config;
import com.ojoin.trade.common.utils.paynow.ThreeDESEncryptProvider;
import com.ojoin.trade.common.web.domain.IDentifiable;

@JsonIgnoreProperties(ignoreUnknown = true)
public class TbSlPlatformUser implements IDentifiable, Serializable {
	/**
	 * 
	 */
	// 电商平台状态
	static final String PLATFORM_STATUS_INITED = "inited"; // 初始

	static final String PLATFORM_STATUS_ENABLED = "enabled"; // 正常抓取

	static final String PLATFORM_STATUS_PAUSED = "paused"; // 申请暂停

	static final String PLATFORM_STATUS_DISABLED = "disabled"; // 已暂停

	private static final long serialVersionUID = 1L;

	public static String needBindAlipay = "1";

	public static String notNeedBindAlipay = "0";

	private Integer id;

	private Integer idOfTbMerchantUser;

	private Integer platformRuleId;

	private String platformName;

	private String platformCnname;

	private String username;

	private String password;

	private String companyName;
	// default(supplyloan)
	private String loginWay ;

	// 需要绑定支付宝 (1 需要, 0 不需要)
	private String bindAlipay;
 
	private String enableFlag;

	private String disableDate;

	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date rowUpdateTime;

	private Date rowCreateTime;

	private String verifyCodeCheck;

	private String certificateCheck;

	private String busiContract;

	@Max(value = 90, message = "融资折扣最高90%")
	@Min(value = 30, message = "融资折扣最低30%")
	@NotBlank(message = "融资折扣不能为空")
	private String discount;

	@NotBlank(message = "融资日利率不能为空")
	private String rate;

	@NotBlank(message = "融资手续费率不能为空")
	private String fee;

	@NotBlank(message = "最高融资额度不能为空")
	private String maxAmount;

	@NotBlank(message = "最长放款期限不能为空")
	private String loanPeriod;

	@NotBlank(message = "授信凭证不能为空")
	private String creditCertificate;

	private String creditcheckCertificate;

	private Integer idOfFinaceaccount;
	
	@NotBlank(message="上下游合同到期日不能为空")
    private String contractExpireDate;

	public Integer getIdOfFinaceaccount() {
		return idOfFinaceaccount;
	}

	public void setIdOfFinaceaccount(Integer idOfFinaceaccount) {
		this.idOfFinaceaccount = idOfFinaceaccount;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getIdOfTbMerchantUser() {
		return idOfTbMerchantUser;
	}

	public void setIdOfTbMerchantUser(Integer idOfTbMerchantUser) {
		this.idOfTbMerchantUser = idOfTbMerchantUser;
	}

	public String getPlatformCnname() {
		return platformCnname;
	}

	public void setPlatformCnname(String platformCnname) {
		this.platformCnname = platformCnname == null ? null : platformCnname
				.trim();
	}

	public Integer getPlatformRuleId() {
		return platformRuleId;
	}

	public void setPlatformRuleId(Integer platformRuleId) {
		this.platformRuleId = platformRuleId;
	}

	public String getPlatformName() {
		return platformName;
	}

	public void setPlatformName(String platformName) {
		this.platformName = platformName == null ? null : platformName.trim();
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username == null ? null : username.trim();
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password == null ? null : password.trim();
	}

	// 密码加密
	public void encPassword() {
		String DSEKey = Config.getProperty("ipaynow.dsekey");// 3DES需要的key
		this.setPassword(ThreeDESEncryptProvider.encrypt(password, DSEKey));
	}

	// 密码解密
	public void decPassword() {
		String DSEKey = Config.getProperty("ipaynow.dsekey");// 3DES需要的key
		this.setPassword(ThreeDESEncryptProvider.decrypt(password, DSEKey));
	}

	public String getEnableFlag() {
		return enableFlag;
	}

	public void setEnableFlag(String enableFlag) {
		this.enableFlag = enableFlag;
	}

	public String getDisableDate() {
		return disableDate;
	}

	public void setDisableDate(String disableDate) {
		this.disableDate = disableDate == null ? null : disableDate.trim();
	}

	public Date getRowUpdateTime() {
		return rowUpdateTime;
	}

	public void setRowUpdateTime(Date rowUpdateTime) {
		this.rowUpdateTime = rowUpdateTime;
	}

	public Date getRowCreateTime() {
		return rowCreateTime;
	}

	public void setRowCreateTime(Date rowCreateTime) {
		this.rowCreateTime = rowCreateTime;
	}

	public String getVerifyCodeCheck() {
		return verifyCodeCheck;
	}

	public void setVerifyCodeCheck(String verifyCodeCheck) {
		this.verifyCodeCheck = verifyCodeCheck == null ? null : verifyCodeCheck
				.trim();
	}

	public String getCertificateCheck() {
		return certificateCheck;
	}

	public void setCertificateCheck(String certificateCheck) {
		this.certificateCheck = certificateCheck == null ? null
				: certificateCheck.trim();
	}

	public boolean isDefaultLoginWay() {
		return "default".equals(getLoginWay());
	}

	public String getLoginWay() {
		return loginWay;
	}

	public void setLoginWay(String loginWay) {
		this.loginWay = loginWay == null ? null : loginWay.trim();
	}

	public String getBusiContract() {
		return busiContract;
	}

	public void setBusiContract(String busiContract) {
		this.busiContract = busiContract == null ? null : busiContract.trim();
	}

	public String getDiscount() {
		return discount;
	}

	public void setDiscount(String discount) {
		this.discount = discount == null ? null : discount.trim();
	}

	public String getRate() {
		return rate;
	}

	public void setRate(String rate) {
		this.rate = rate == null ? null : rate.trim();
	}

	public String getFee() {
		return fee;
	}

	public void setFee(String fee) {
		this.fee = fee == null ? null : fee.trim();
	}

	public String getMaxAmount() {
		return maxAmount;
	}

	public void setMaxAmount(String maxAmount) {
		this.maxAmount = maxAmount == null ? null : maxAmount.trim();
	}

	public String getCreditCertificate() {
		return creditCertificate;
	}

	public void setCreditCertificate(String creditCertificate) {
		this.creditCertificate = creditCertificate == null ? null
				: creditCertificate.trim();
	}

	public String getLoanPeriod() {
		return loanPeriod;
	}

	public void setLoanPeriod(String loanPeriod) {
		this.loanPeriod = loanPeriod;
	}

	public String getCreditcheckCertificate() {
		return creditcheckCertificate;
	}

	public void setCreditcheckCertificate(String creditcheckCertificate) {
		this.creditcheckCertificate = creditcheckCertificate == null ? null
				: creditcheckCertificate.trim();
	}

	public String getBindAlipay() {
		return bindAlipay;
	}

	public void setBindAlipay(String bindAlipay) {
		this.bindAlipay = bindAlipay;
	}
	
	public String getContractExpireDate() {
		return contractExpireDate;
	}

	public void setContractExpireDate(String contractExpireDate) {
		this.contractExpireDate = contractExpireDate;
	}

	@Override
	public String getTableName() {
		return "tb_sl_platform_user";
	}
	 
	
	public  void buildDefaultEntity(){
		if(null==this.getLoginWay()){
			this.setLoginWay("default");
		}
		if(null==this.getEnableFlag()){
			this.setEnableFlag(PLATFORM_STATUS_INITED);
		}
		if(null==this.getVerifyCodeCheck()){
			this.setVerifyCodeCheck("0");
		}
		if(null==this.getCertificateCheck()){
			this.setCertificateCheck("0");
		}
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
}